package com.mobile.collect.present;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.mobile.collect.R;
import com.mobile.collect.activitys.SealingPointActivity;
import com.mobile.collect.beans.SealPointInfo;

import cn.droidlover.xdroidmvp.base.ListViewChildClickListener;
import cn.droidlover.xdroidmvp.mvp.XPresent;

public class SealingPointPresent extends XPresent<SealingPointActivity> {

    public View getSealPointView(SealPointInfo sealPointInfo, final int position, final ListViewChildClickListener childClickListener) {
        LayoutInflater inflater = LayoutInflater.from(getV());
        View itemView = inflater.inflate(R.layout.item_sealingpoint, null, false);
        TextView childTypeTv = itemView.findViewById(R.id.childTypeTv);
        TextView dimenTv = itemView.findViewById(R.id.dimenTv);
        TextView numberTv = itemView.findViewById(R.id.numberTv);
        TextView descTv = itemView.findViewById(R.id.descTv);
        ImageView delIv = itemView.findViewById(R.id.delIv);
        ImageView descMoreIv = itemView.findViewById(R.id.descMoreIv);


        childTypeTv.setText(sealPointInfo.getChildTypeEn());
        dimenTv.setText(sealPointInfo.getDimen());
        numberTv.setText(String.valueOf(sealPointInfo.getCount()));
        descTv.setText(sealPointInfo.getDesc());

        sealPointInfo.setDimenTv(dimenTv);
        sealPointInfo.setChildTypeTv(childTypeTv);
        sealPointInfo.setNumberTv(numberTv);
        sealPointInfo.setDescTv(descTv);

        childTypeTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                childClickListener.itemChildClick(position, R.id.childTypeTv);
            }
        });
        numberTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                childClickListener.itemChildClick(position, R.id.numberTv);
            }
        });
        dimenTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                childClickListener.itemChildClick(position, R.id.dimenTv);
            }
        });
        descMoreIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                childClickListener.itemChildClick(position, R.id.descMoreIv);
            }
        });
        delIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                childClickListener.itemChildClick(position, R.id.delIv);
            }
        });

        return itemView;
    }
}
